﻿namespace dPet.Domain.Events.Handlers
{
	using dPet.Domain.Models;
	using dPet.Domain.Services;
	using Hangerd.Event;

	public class SaleOrderCanceledEventHandler : IDomainEventHandler<SaleOrderCanceledEvent>
	{
		private readonly IInvoicingDomainService _invoicingDomainService;

		public SaleOrderCanceledEventHandler(IInvoicingDomainService invoicingDomainService)
		{
			_invoicingDomainService = invoicingDomainService;
		}

		public void Handle(SaleOrderCanceledEvent e)
		{
			var order = e.Source as SaleOrder;

			_invoicingDomainService.ReturnInventoryByOrder(order);
		}
	}
}
